package service

import (
	"context"
	__ "mt-server/basic/proto"
	"mt-server/handler/model"
)

// 商家查看预约列表
func (s *Server) ListAppointment(_ context.Context, in *__.ListAppointmentReq) (*__.ListAppointmentResp, error) {

	var or model.Appointment

	order, total, _ := or.ListAppointment(int(in.Page), int(in.PageSize))

	var list []*__.GetAppointment

	for _, val := range order {
		list = append(list, &__.GetAppointment{
			NumberPeople: int64(val.NumberPeople),
			Information:  val.Information,
			Status:       val.Status,
			Reminder:     val.Reminder,
		})
	}
	return &__.ListAppointmentResp{
		List:     list,
		Page:     in.Page,
		PageSize: in.PageSize,
		Total:    total,
	}, nil
}
